// components/tableGroup/index.js
const app = getApp()
Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    Arr: [
      {
        dragId: "0",
        title: "西游记",
        images: "/assets/image/swipe/1.png",
        fixed: false
      },
      {
        dragId: "1",
        title: "红楼梦",
        images: "/assets/image/swipe/2.png",
        fixed: false
      },
      {
        dragId: "2",
        title: "西游记1",
        images: "/assets/image/swipe/3.png",
        fixed: false
      },
      {
        dragId: "3",
        title: "红楼梦1",
        images: "/assets/image/swipe/4.png",
        fixed: false
      },
      {
        dragId: "4",
        title: "西游记2",
        images: "/assets/image/swipe/5.png",
        fixed: false
      },
      {
        dragId: "5",
        title: "红楼梦2",
        images: "/assets/image/swipe/6.png",
        fixed: false
      },
    ],
    isIphoneX: app.globalData.isIphoneX,
		size: 4,
		listData: [],
		extraNodes: [
		],
		pageMetaScrollTop: 0,
		scrollTop: 0
  },

  /**
   * 组件的方法列表
   */
  methods: {
    onLoad(){
      // console.log('123123')
      // this.drag = this.selectComponent('#drag');
      // this.drag.init();
    },
    sortEnd(e) {
      this.setData({
        listData: e.detail.listData
      });
    },
    change(e) {
    },
    sizeChange(e) {
      wx.pageScrollTo({scrollTop: 0})
      this.setData({
        size: e.detail.value
      });
      this.drag.columnChange();
    },
    itemClick(e) {
      let jj = this.data.listData;
      let uu = this.data.Arr;
      jj.some((obj,index)=>{
        if(obj.dragId == e.detail.data.dragId){
          jj.splice(index, 1);
           uu.push(e.detail.data);
          this.setData({
            listData:jj,
            Arr:uu
          })
          this.drag.init();
        }
      })
    },
    toggleFixed(e) {
      let key = e.currentTarget.dataset.key;
  
      let {listData} = this.data;
  
      listData[key].fixed = !listData[key].fixed
  
      this.setData({
        listData: listData
      });
    },
    scroll(e) {
      this.setData({
        pageMetaScrollTop: e.detail.scrollTop
      })
    },
    // 页面滚动
    onPageScroll(e) {
      this.setData({
        scrollTop: e.scrollTop
      });
    },
    clickReturn: function (e) {
      if (e.detail.type == '1') {
        let jj = this.data.Arr;
        jj.some((obj,index) => {
          if (obj.dragId == e.detail.value.dragId) {
            jj.splice(index, 1);
            this.setData({
              Arr:jj,
              listData:this.data.listData.concat(e.detail.value)
            })
            console.log('123----123')
            this.drag = this.selectComponent('#drag');
            this.drag.init();
          }
        })
      } 
  
    }
  }
})
